package com.qidian.zl.paper.filter;

import com.qidian.zl.paper.pojo.Admin;
import com.qidian.zl.paper.service.AdminService;
import com.qidian.zl.paper.service.impl.AdminServiceImpl;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.UUID;

@WebFilter("/*")
public class CharSetFilter implements Filter {

    @Override
    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {

        HttpServletRequest request=(HttpServletRequest) req;
        HttpServletResponse response=(HttpServletResponse)resp;
        request.setCharacterEncoding("utf-8");

        /*String adminName = request.getParameter("adminName");
        String password = request.getParameter("password");


        String groupId = UUID.randomUUID().toString().replace("-", "");

        Cookie cookie=new Cookie("groupId",groupId);
        cookie.setMaxAge(60*60);
        cookie.setPath("/");
        response.addCookie(cookie);*/

        chain.doFilter(request,response);
    }

    @Override
    public void init(FilterConfig config) throws ServletException {

    }

}
